//
//  UIFont+CW.m
//  CWDevelop
//
//  Created by LittoCats on 7/13/14.
//  Copyright (c) 2014 Littocats. All rights reserved.
//

#import "UIFont+CW.h"

@implementation UIFont (CW)

+ (UIFont *)fontWithScript:(NSString *)script
{
    NSArray *fontScript = [script componentsSeparatedByString:@" "];
    
    NSString *fontName = [fontScript firstObject];
    CGFloat fontSize = [[fontScript lastObject] floatValue];
    fontSize = fontSize > 0.0 ? fontSize : 13;
    
    //Can't find font with fontName , use system font
    if (![[UIFont familyNames] containsObject:fontName]) 
        return [UIFont systemFontOfSize:fontSize];
    
    
    return [UIFont fontWithName:fontName size:fontSize];
}

- (NSString *)script
{
    return [NSString stringWithFormat:@"%@ %f",self.fontName, self.pointSize];
}

@end
